<%@ page import="id.co.gomobile.assessment.Test" %>
<%@ page import="id.co.gomobile.assessment.Preference"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title>Test Details</title>
    </head>
    <body>
    <g:render template="/shared/navigation" />
    
    <div id="body">
    
    <h1>Test Details</h1>

    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>

    <div class="dialog">

    <fieldset>
 
            <h3>General Information</h3>
            <div class="dialog">
                <table>
                    <col width="200px" />
                    <tbody>
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="test.id.label" default="Id" /></td>
                            <td valign="top" class="value">${fieldValue(bean: testInstance, field: "id")}</td>
                        </tr>

                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="test.name.label" default="Name" /></td>
                            <td valign="top" class="value">${fieldValue(bean: testInstance, field: "name")}</td>
                        </tr>
                    
                        <tr class="prop">
                            <td valign="top" class="name"><g:message code="test.description.label" default="Description" /></td>
                            <td valign="top" class="value">${fieldValue(bean: testInstance, field: "description")}</td>
                        </tr>
                    
                    </tbody>
                </table>
            </div>
            <br/>
            <h3>Preference</h3>
            <div class="dialog">
            <table>
                <col width="200px" />
                <tbody>
                    <tr class="prop">
                        <td valign="top" class="name"><g:message code="test.preference.timeout.label" default="Timeout" /></td>
                        <td valign="top" class="value">${fieldValue(bean: testInstance, field: "preference.timeout")}</td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name"><g:message code="test.preference.maxQuestions.label" default="Max. Questions" /></td>
                        <td valign="top" class="value">${fieldValue(bean: testInstance, field: "preference.maxQuestions")}</td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name"><g:message code="test.preference.maxQuestionsPerPage.label" default="Max. Questions / Page" /></td>
                        <td valign="top" class="value">${fieldValue(bean: testInstance, field: "preference.maxQuestionsPerPage")}</td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name"><g:message code="test.preference.forceSubmitOnTimeout.label" default="Force Submit On Timeout" /></td>
                        <td valign="top" class="value"><g:formatBoolean boolean="${testInstance?.preference?.forceSubmitOnTimeout}" true="Yes" false="No" /></td>
                    </tr>

                </tbody>
            </table>
            </div>
 
        <br/>

        <div class="buttons">
            <g:form>
                <g:hiddenField name="id" value="${testInstance?.id}" />
                <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'default.button.edit.label', default: 'Edit')}" /></span>
                <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
            </g:form>
        </div>
        
    </fieldset>

    <br/>

    <fieldset>
    
    <h3>List of Items</h3>
    
    <div class="list">
    <table>
        <col width="50" />
        <col />
        <col width="150" />
        <col width="150" />
        <col width="150" />
        <thead>
            <tr>
                <th colspan="5" align="right">${itemInstanceList.size()} displayed</th>
            </tr>
            <tr>
                <g:sortableColumn property="id" title="${message(code: 'test.id.label', default: 'Id')}" />
                <g:sortableColumn property="text" title="${message(code: 'test.text.label', default: 'Text')}" />
                <th title="Type">Type</th>
                <g:sortableColumn property="category" title="${message(code: 'test.category.label', default: 'Category')}" />
                <th title="Action">Action</th>
            </tr>
        </thead>
        <tbody>
        <g:each in="${itemInstanceList}" status="i" var="itemInstance">
            <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                <td>${fieldValue(bean: itemInstance, field: "id")}</td>
                <td>${fieldValue(bean: itemInstance, field: "text")}</td>
                <td>${itemInstance.type()}</td>
                <td>${fieldValue(bean: itemInstance, field: "category")}</td>
                <td style="text-align: center">
                    <g:form controller="item" action="show" id="${itemInstance?.id}" style="display: inline">
                        <input type="image" src="${resource(dir:'images/skin', file:'database_table.png')}" alt="Show Test" />
                    </g:form>
                    &nbsp;
                    <g:form controller="item" action="edit" id="${itemInstance?.id}" style="display: inline">
                        <input type="image" src="${resource(dir:'images/skin', file:'database_edit.png')}" alt="Edit Test" />
                    </g:form>
                    &nbsp;
                    <g:form controller="item" action="delete" id="${itemInstance?.id}" style="display: inline">
                        <input type="image" src="${resource(dir:'images/skin', file:'database_delete.png')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" alt="Delete Question" />
                    </g:form>
                </td>
            </tr>
        </g:each>
        </tbody>
    </table>
    </div>

    <br/>
    
    <div class="buttons">
        <g:form controller="item">
            <g:hiddenField name="test.id" value="${testInstance?.id}" />
            <span class="button"><g:actionSubmit class="create" action="create" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
        </g:form>
    </div>

    </fieldset>

    </div>
    
    </div>
    </body>
</html>